package com.example.horizontalrefresh.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;

import com.example.horizontalrefresh.R;
import com.example.horizontalrefresh.entity.TestData;

import java.util.List;

/**
 * @ProjectName: zhcg6
 * @Package: com.tfrd.city.adapter
 * @ClassName: TestDataAdapter
 * @Description:
 * @Author: 作者名：zhy
 * @CreateDate: 2019/8/20 17:07
 */
public class TestDataAdapter extends  RecyclerView.Adapter<TestDataAdapter.TestHolder> {

    private TestClickLitener mTestClickLitener;
    private Context mContext;
    private List<TestData> testData;

    public TestDataAdapter(Context mContext, List<TestData> caseInfoVos) {
        this.mContext = mContext;
        this.testData = caseInfoVos;
    }

    public void setTestClickLitener(TestClickLitener mSubmitOnItemClickLitener) {
        this.mTestClickLitener = mSubmitOnItemClickLitener;
    }


    @NonNull
    @Override
    public TestHolder onCreateViewHolder(@NonNull ViewGroup viewGroup, int i) {
        return new TestHolder(LayoutInflater.from(mContext).inflate(R.layout.item_test_data, viewGroup, false));
    }

    @Override
    public void onBindViewHolder(@NonNull TestHolder testHolder, int position) {
        TestData caseInfo = testData.get(position);
        testHolder.tv1.setText(caseInfo.getTextName());
        testHolder.tv2.setText(caseInfo.getTextAge());
    }

    @Override
    public int getItemCount() {
        return testData.size();
    }

    class TestHolder extends RecyclerView.ViewHolder {
        TextView tv1,tv2;

        public TestHolder(View view) {
            super(view);
            tv1 = view.findViewById(R.id.text1);
            tv2 = view.findViewById(R.id.text2);
        }
    }

    public interface TestClickLitener {
        void onItemClick(int position);

        void onLongClick(int position);
    }
}
